package app

import (
	"github.com/gin-gonic/gin"
)

type Gin struct {
	C *gin.Context
}

type Response struct {
	Code string         `json:"code"`
	Data interface{} `json:"data"`
}

type ErrorResponse struct {
	Code string         `json:"code"`
	Msg  string      `json:"msg"`
}

func (g *Gin) Response(httpCode int, data interface{}) {
	g.C.JSON(httpCode, Response{
		Code: "success",
		Data: data,
	})
	return
}

func (g *Gin) ErrorResponse(httpCode int, msg string) {
	g.C.JSON(httpCode, ErrorResponse{
		Code: "error",
		Msg: msg,
	})
	return
}